/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vamprest;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author sav
 */
@Entity
@Table(name = "route")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Route.findAll", query = "SELECT r FROM Route r"),
    @NamedQuery(name = "Route.findByIdroute", query = "SELECT r FROM Route r WHERE r.idroute = :idroute")})
public class Route implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "idroute")
    private Integer idroute;
    @Lob
    @Size(max = 65535)
    @Column(name = "comment")
    private String comment;
    @JoinTable(name = "transit", joinColumns = {
        @JoinColumn(name = "idroutearrival", referencedColumnName = "idroute")}, inverseJoinColumns = {
        @JoinColumn(name = "idroutedeparture", referencedColumnName = "idroute")})
    @ManyToMany
    private Collection<Route> routeCollection;
    @ManyToMany(mappedBy = "routeCollection")
    private Collection<Route> routeCollection1;
    @JoinColumn(name = "idmember", referencedColumnName = "idmember")
    @ManyToOne(optional = false)
    private Member idmember;
    @JoinColumn(name = "idadress", referencedColumnName = "iddadress")
    @ManyToOne(optional = false)
    private Address idadress;

    public Route() {
    }

    public Route(Integer idroute) {
        this.idroute = idroute;
    }

    public Integer getIdroute() {
        return idroute;
    }

    public void setIdroute(Integer idroute) {
        this.idroute = idroute;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    @XmlTransient
    public Collection<Route> getRouteCollection() {
        return routeCollection;
    }

    public void setRouteCollection(Collection<Route> routeCollection) {
        this.routeCollection = routeCollection;
    }

    @XmlTransient
    public Collection<Route> getRouteCollection1() {
        return routeCollection1;
    }

    public void setRouteCollection1(Collection<Route> routeCollection1) {
        this.routeCollection1 = routeCollection1;
    }

    public Member getIdmember() {
        return idmember;
    }

    public void setIdmember(Member idmember) {
        this.idmember = idmember;
    }

    public Address getIdadress() {
        return idadress;
    }

    public void setIdadress(Address idadress) {
        this.idadress = idadress;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idroute != null ? idroute.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Route)) {
            return false;
        }
        Route other = (Route) object;
        if ((this.idroute == null && other.idroute != null) || (this.idroute != null && !this.idroute.equals(other.idroute))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "vamprest.Route[ idroute=" + idroute + " ]";
    }

}
